# 使用进程池创建进程
import os
import time
from multiprocessing import Pool


def work(num):
    print('进程%s:执行任务%d' % (os.getpid(), num))
    time.sleep(2)


if __name__ == '__main__':
    pool = Pool(4)
    for i in range(9):
        pool.apply_async(work, (i,))
    time.sleep(3)
    pool.close()
    # pool.join()
    print("主进程执行结束")
